<script type="text/javascript">
	<?php $timestamp = time();?>
	$(function() {
		var id = "[picid]";
		var name = "[name]";
		var buttonText = "[text]";
		var upthumb = "[class]";
		var uploadLimit = "[limit]";
		var multi = true;
		if(buttonText == '' || buttonText == '['+'text'+']'){
			buttonText = '图片上传';
		}
		if(upthumb == '' || upthumb == '['+'class'+']'){
			upthumb = 'upthumb';
		}
		if(uploadLimit == '' || uploadLimit == '['+'limit'+']'){
			uploadLimit = 0;
			multi = false;
		}
		$('#'+id).uploadAdapter({
			'formData'     : {
				'timestamp' : '<?php echo $timestamp;?>',
				'token'     : '<?php echo md5('xiaobai_self' . $timestamp);?>'
			},
			//removeCompleted : false,
			auto     : true,//自动上传
			uploader : "{:Url('Uploads/thumb')}",
            fileObjName: 'file',
			cancelImage: '__JS__/uploadify/uploadify/uploadify-cancel.png',//[必须设置]取消图片的路径
			fileSizeLimit: '2MB',
			height: 28,//上传按钮的高和宽
			width: 100,
			debug: false,//debug模式开/关，打开后会显示debug时的信息
			multi: multi,//是否多文件上传
			uploadLimit : uploadLimit,  //最多只允许上传10张图片，0不限制
			fileTypeDesc: 'file(*.jpg;*.jpeg;*.gif;*.png;*.JPG;*.JPEG;*.GIF;*.PNG)',//对话框的文件类型描述
			fileTypeExts: 'image/png,image/jpg,image/jpeg,image/gif',//可上传的文件类型
			buttonText: buttonText,//通过文字替换钮扣上的文字
			onUploadSuccess : function(file, data, response){
				var res = eval('(' + data + ')');
				if(res.status){
                    data = res.data;
					$('#'+file.id).find('.data').html(' 上传完毕');
					var html = '<li class="li_'+data.id+'">';
					html += '<input type="hidden" name="'+name+'" value="'+data.url+'" />';
					html += '<div class="upload_img_div"><a href="'+data.url+'" class="cboxElement">';
                    html += '<img src="'+data.url+'" alt="'+data.name+'" class="img-responsive" /></a></div>';
					html += '<div class="tools tools-top">';
					html += '<a href="javascript:;" onclick="remove_img(\'li_'+data.id+'\');"><i class="fa fa-remove red"></i></a>';
					html += '</div></li>';
					if(!multi){
						$("."+upthumb).html(html);
					}else{
						$("."+upthumb).append(html);
					}
				}else{
					layer.alert(data.msg, {icon: 0});
				}
			}, 
		});
	});
</script>